import Vue from 'vue'

import Cookies from 'js-cookie'

import 'normalize.css/normalize.css' // A modern alternative to CSS resets

import './assets/style.scss'
import './styles/element-variables.scss'
import '@/styles/index.scss' // global css

/*import 'element-ui/lib/theme-chalk/index.css'
import locale from 'element-ui/lib/locale/lang/zh-CN' // lang i18n
import Element from 'element-ui'
Vue.use(Element, {
  locale,
  size: Cookies.get('size') || 'medium' // set element-ui default size
})*/


import App from './App'
import store from './store'
import router from './router'

import '@/icons' // icon
import '@/permission' // permission control
import './utils/error-log' // error log

import * as filters from './filters' // global filters

/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online ! ! !
 */
if (process.env.NODE_ENV === 'production') {
  const { mockXHR } = require('../mock')
  mockXHR()
}

Vue.prototype.notify = function (result, content, duration){
  this.$notify.closeAll()

  if (content === undefined) {
    content = result.content
  }
  if (duration === undefined) {
    duration = 4000
  }
  this.$notify({
    title: result.success?'成功':'失败',
    type: result.success?'success':'error',
    message: content,
    duration: duration
  });
}

Vue.prototype.isNull = function (str){
  if (str === null || str === undefined || str.length === 0) {
    return true
  }
  return false
}


// set ElementUI lang to EN
// Vue.use(ElementUI, { locale })
// 如果想要中文版 element-ui，按如下方式声明
// Vue.use(ElementUI)


// register global utility filters
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
})

//全局配置fast dfs file callback uri this.fastDfsCallbackUri
//development
// Vue.prototype.fastDfsCallbackUri = 'http://192.168.110.100:8080/'
//production
Vue.prototype.fastDfsCallbackUri = process.env.VUE_APP_Fastdfs_Callback

Vue.config.productionTip = false

new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})
